<?php
namespace app\traits\model;

trait DataFilter{
    public function scopeDataFilter($query){
        if (property_exists($this, 'field')) {
            return $query->where('create_by',request()->creatorId);
        }
        //  判断是否有创建者字段
        if (property_exists($this, 'field') && in_array('create_by', $this->field) && request()->data_scope == 2) {
            return $query->where('create_by',request()->creatorId);
        }
        return $query;
    }
}